package com.zttek.videoShareProject.modules.web;


import com.zttek.videoShareProject.common.base.MyBaseController;
import com.zttek.videoShareProject.common.json.VideoVO;
import com.zttek.videoShareProject.modules.service.IVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CBY
 * @since 2018-07-11
 */
@Controller
@RequestMapping("/history")
public class HistoryController extends MyBaseController {

    @Autowired
    IVideoService videoService;
    /**
     * 返回用户观看历史的视频数据，按观看时间排序
     *
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping(value = "history_video",method = RequestMethod.GET)
    public Object showOneVideo (@RequestParam("user_id") Long user_id){
        List<VideoVO.HistoryVideo> list = null;
        try {
            if(user_id>0)
            list=videoService.HistoryVideo(user_id);
        } catch (Exception e) {
            e.printStackTrace();
            renderError();
        }
        return renderSuccess(list);
    }
}
